/**
 * @Author George.
 * @Date 2019/1/10.
 * @Description: 简化Vue内置方法.
 */
import {
    GetRequest
} from "../js/common.js";
let MyPlugin = {};
MyPlugin.install = function(Vue, options) {
    // 1. 添加全局方法或属性

    Vue.showCustomToast = (msg, icon = false, opts = {}) => {
        let option = Object.assign({
            title: msg,
            icon: icon || "none",
            duration: 2000
        }, opts);
        uni.showToast(option)
    };

    Vue.customNavigateTo = url => {
        uni.navigateTo({
            url: url
        })
    };

    Vue.customRedirectTo = url => {
        uni.redirectTo({
            url: url
        })
    };
    Vue.customSwitchTab = url => {
        uni.switchTab({
            url: url
        })
    };

    Vue.customReLaunch = url => {
        uni.reLaunch({
            url: url
        })
    };

    Vue.customNavigateBack = history => {
        uni.navigateBack({
            delta: history || 1
        })
    };

    Vue.showCustomLoading = title => {
        uni.showLoading({
            mask: true,
            title: title || '加载中...'
        })
    };

    Vue.customSetNavigationBarTitle = title => {
        uni.setNavigationBarTitle({
            title: title
        })
    };
}
export default MyPlugin